{include file="common/header.tpl"}
<section class="main">
	<nav class="left-col">{include file="common/navi-category.tpl"}</nav>
    <article class="right-col"><h2>{$arrSmarty.category[$smarty.get.type]}{if isset($smarty.session.category) && ($smarty.session.category&1<<0) > 0} &raquo; <a href="{$smarty.const.HOST_BACKEND}category/add?type={$smarty.get.type}">{$arrSmarty.add}</a>{/if}</h2>
        {include file="category/search.tpl"}
        <form name="frmCategory" id="frmCategory" action="{$smarty.const.HOST_BACKEND}category/act" method="post" enctype="multipart/form-data">
            <input type="hidden" name="paction" id="paction"/>
            <input type="hidden" name="pbackurl" id="pbackurl" value="{$smarty.const.HOST_BACKEND}category/index"/>           
            {if $arrResult}
                {if ($smarty.session.category) > 0}
                    <div class="s-button">
                        {if ($smarty.session.category&1<<4) > 0}
                            <button type="button" onclick="javascript:confirmPending(this.form);">{$arrSmarty.btn_suspend}</button>
                        {/if} 
                        {if ($smarty.session.category&1<<5) > 0}
                            <button type="button" onclick="javascript:confirmActive(this.form);">{$arrSmarty.btn_active}</button>
                        {/if}                                                                                  
                        {if ($smarty.session.category&1<<3) > 0}  
                            <button type="button" onclick="javascript:confirmDelete(this.form);">{$arrSmarty.btn_delete}</button>
                            {if $AppUI->type == 3}
                                <button type="button" onclick="javascript:confirmDeleteDb(this.form);">{$arrSmarty.btn_delete_db}</button>
                            {/if}
                        {/if}
                    </div>
                {/if}
                {if $intTotal > 0}
                    <div class="s-page">
                    	<strong class="total">Tổng số: {$intTotal}</strong>
                        {paging total=$intTotal limit=$intLimit offset=$intOffset url=$strUrl}
                    </div>
                {/if}
            {/if}
            <table width="100%" cellpadding="0" cellspacing="0" border="0" class="list">
                <thead>
                    <tr>
                        {if $arrResult && isset($smarty.session.category) && ( (($smarty.session.category&1<<3)>0) || (($smarty.session.category&1<<4)>0) )}
                            <th width="30"><input type="checkbox" name="pcheckall" id="pcheckall" onclick="javascript:checkAll(this.form,'pcategoryid[]',this.checked);"/></th>                                
                        {/if}   
                        <th>{$arrSmarty.name}</th>
                        <th width="200">{$arrSmarty.parent}</th>                             
                        <th width="90">{$arrSmarty.iseq}</th>
                        <th width="120">Khu vực hiển thị</th>                                       
                        <th width="80">{$arrSmarty.status}</th> 
                        <th width="120">{$arrSmarty.postdate}</th>                                       
                        {if $arrResult && isset($smarty.session.category)}
                            <th width="50">&nbsp;</th>
                        {/if}
                    </tr>
                </thead>
                <tbody>
                    {if $arrResult}
                        {foreach item=item from=$arrResult}
                            <tr class="{cycle values="odd,even"}">
                                {if isset($smarty.session.category) && ((($smarty.session.category&1<<3)>0) || (($smarty.session.category&1<<4)>0))}
                                    <td align="center">
                                        <input type="checkbox" id="pcategoryid{$item.categoryid}" name="pcategoryid[]" value="{$item.categoryid}" onclick="javascript:checkOneItem(this.form, 'pcheckall')"/>
                                    </td>
                                {/if}
                                <td>{if $item.parentid > 0}|---- {/if}{$item.name}</td>
                                <td>{if $item.parentid > 0}{$item.parent_name}{else}-----//-----{/if}</td>
                                <td align="right">{$item.iseq}</td>
                                <td>{$arrSmarty.adv[$item.adv]}</td>
                                <td align="center">
                                    {if $item.status == 0}
                                        <img src="{$smarty.const.HOST_STATICS}backend/img/ad-unaccept.png" width="16" height="" alt="Tạm dừng" border="0" title="Tạm dừng" />
                                    {elseif $item.status == 1}
                                         <img src="{$smarty.const.HOST_STATICS}backend/img/ad-accept.png" alt="Đang kích hoạt" border="0" width="16" height="16" />
                                    {elseif $item.status == 2}
                                        <img src="{$smarty.const.HOST_STATICS}backend/img/ad-cancel.png" alt="Bị xóa" border="0" width="16" height="16" />
                                    {/if}
                                </td>  
                                <td>{$item.postdate|date_format:"%d/%m/%Y %H:%M:%I"}</td>                                             
                                <td align="center">
                                    {if isset($smarty.session.category)}                                                    	
                                        {if $item.parentid == 0 && ($smarty.session.category&1<<1)>0}
                                            <a href="{$smarty.const.HOST_BACKEND}category/add?parentid={$item.categoryid}" title="Thêm phân loại cấp 2" ><img src="{$smarty.const.HOST_STATICS}backend/img/ad-add.png" alt="Thêm phân loại cấp 2" border="0" width="16" height="16"/></a>
                                        {/if}
                                        {if ($smarty.session.category&1<<2)>0}
                                            <a href="{$smarty.const.HOST_BACKEND}category/edit?categoryid={$item.categoryid}&amp;type={$item.type}" title="Cập nhật thông tin">
                                                <img src="{$smarty.const.HOST_STATICS}backend/img/ad-edit.png" alt="Edit" border="0" width="16" height="16" />
                                            </a>
                                        {/if}
                                    {else}
                                        &nbsp;
                                    {/if}
                                </td>
                            </tr>
                        {/foreach}
                    {else}
                        <tr><td colspan="6" align="center">Không có dữ liệu</td></tr>
                    {/if}
                </tbody>
            </table>
            {if $arrResult}
            	{if $intTotal > 0}
                    <div class="s-page">
                    	<strong class="total">Tổng số: {$intTotal}</strong>
                        {paging total=$intTotal limit=$intLimit offset=$intOffset url=$strUrl}
                    </div>
                {/if}
                {if ($smarty.session.category) > 0}
                    <div class="s-button">
                        {if ($smarty.session.category&1<<4) > 0}
                            <button type="button" onclick="javascript:confirmPending(this.form);">{$arrSmarty.btn_suspend}</button>
                        {/if} 
                        {if ($smarty.session.category&1<<5) > 0}
                            <button type="button" onclick="javascript:confirmActive(this.form);">{$arrSmarty.btn_active}</button>
                        {/if}                                                                                  
                        {if ($smarty.session.category&1<<3) > 0}  
                            <button type="button" onclick="javascript:confirmDelete(this.form);">{$arrSmarty.btn_delete}</button>
                            {if $AppUI->type == 3}
                                <button type="button" onclick="javascript:confirmDeleteDb(this.form);">{$arrSmarty.btn_delete_db}</button>
                            {/if}
                        {/if}
                    </div>
                {/if}
            {/if}
        </form>
   	</article>
</section>
{include file="common/footer.tpl"}
                
